/************************************************************
* @file   system_retmem.h
* @brief  retention memory
************************************************************/
#ifndef GKT_RETMEM_H
#define GKT_RETMEM_H
	
#include "gkt_peripherals.h"
	
#ifdef __cplusplus
	extern "C" {
#endif

/************************************************************
* BPK Key:A total of 32 Uint32_t 
*		  uint32_t [0]:system used
*			   Byte[0]:
*			   		0bit--Mark Whether to wake up
*			   		1bit--Mark whether the watchdog is reset
*			   		2bit--Mark whether the marking is soft reset
*			   Byte[1]: wdte busy bits
*
*         uint32_t [1]:			   
*			   Byte[0]:door tamper used 
*					--io1  :door tamper detect level
*			   		--io1~2:door tamper gpio io number
*              Byte[1]:door lock used
*					Record door lock status
*
*         uint32_t [2]:RFID used
*			   Byte[0]:RFID record water level
*			   Byte[1]:RFID record active water level
*			   Byte[2]:RFID record standby mode
*			   Byte[3]:RFID record chip type
*
*		  uint32_t [3]:keypad used
*			   Byte[0]:Record how many key chips are used 12/15 CH
*			   Byte[1]:Record keypad calibration has failed
*			   Byte[2]:Record whether to use sensitivity or standard parameters
*				
*		  uint32_t [4]:window_retmem_data
*			   record verify failed counts
*
*		  uint32_t [5]:window_retmem_data
*              record verify failed expire dtu
*
*		  uint32_t [6]:window_retmem_data
*              record verify locked clear_dtu
*		
*		  uint32_t [7]:user dynpwd info
*			   Byte[0]:
*			   Byte[1]:admin item indexs[pwd admin 0]
*			   Byte[2]:
*			   Byte[3]:admin item indexs[pwd admin 1]
*		  uint32_t [8]:user dynpwd info
*			   Byte[0]:
*			   Byte[1]:admin item indexs[pwd admin 2]
*			   Byte[2]:
*			   Byte[3]:admin item indexs[pwd admin 3]
*
*		  			   user dynpwd totp enable
*		  uint32_t [9]:password admin 0
*		  uint32_t [10]:password admin 1
*		  uint32_t [11]:password admin 2
*		  uint32_t [12]:password admin 3
*		  uint32_t [13]:rtc alarm
*
*					   network enable
*		  uint32_t [14]:wait remote unlock response
*
*					   face id enable
*		  uint32_t [15]:face id nomatch cnt
*		  uint32_t [16]:face id nomatch clear dtu
*
*		  			   proximity sensor enable
*         uint32_t [17]:
*			   Byte[0~1]:proximity power state
*              Byte[2~3]:proximity power count
*		  uint32_t [18]:proximity power clear dtu
*
*		  uint32_t [19]:proximity sensor type
*
*		  uint32_t [20]:rtc rc source
*		  uint32_t [21]:touch panel type
*		  uint32_t [22]:Record always mode status
*		  uint32_t [23]:
*		  uint32_t [24]: 
*		  uint32_t [25]:
*		  uint32_t [26]: 
*		  uint32_t [27]:
*		  uint32_t [28]: 
*		  uint32_t [29]:
*		  uint32_t [30]: 
*		  uint32_t [31]: 
************************************************************/
enum {
	GKT_RETMEM_SYSTEM_WAKEUP = 0,
	GKT_RETMEM_DOOR_RELATE,							/*1*/
	GKT_RETMEM_RFID,								/*2*/
	GKT_RETMEM_KEYPAD,								/*3*/
	GKT_RETMEM_WINDOW_VERIFY_FAIL_CNT,				/*4*/
	GKT_RETMEM_WINDOW_VERIFY_EXPIRE_DTU,			/*5*/
	GKT_RETMEM_WINDOW_VERIFY_LOCK_CLEAR_DTU,		/*6*/
	GKT_RETMEM_USER_DYNPWD_INFO0_1,					/*7*/
	GKT_RETMEM_USER_DYNPWD_INFO2_3,					/*8*/
	GKT_RETMEM_USER_DYNPWD_ADMIN0_PWD,				/*9*/
	GKT_RETMEM_USER_DYNPWD_ADMIN1_PASSWORD,			/*10*/
	GKT_RETMEM_USER_DYNPWD_ADMIN2_PASSWORD,			/*11*/
	GKT_RETMEM_USER_DYNPWD_ADMIN3_PASSWORD,			/*12*/
	GKT_RETMEM_RTC_ALARM,							/*13*/
	GKT_RETMEM_NETWORK_WAIT_REMOTE_UNLOCK_RESPONSE,	/*14*/
	GKT_RETMEM_FACE_ID_NOMATCH_CNT,					/*15*/
	GKT_RETMEM_FACE_ID_NOMATCH_CLEAR_DTU,			/*16*/
	GKT_RETMEM_PROXIMITY_POWER_STATE_COUNT,			/*17*/
	GKT_RETMEM_PROXIMITY_POWER_CLEAR_DTU,			/*18*/
	GKT_RETMEM_PROXIMITY_SENSOR_TYPE,				/*19*/
	GKT_RETMEM_RTC_RC_SOURCE,						/*20*/
	GKT_RETMEM_TOUCH_PANEL_TYPE,					/*21*/
	GKT_RETMEM_ALWAYS_MODE_STATUS,					/*22*/
	
	GKT_RETMEM_MAX
};

#if GKT_RETMEM_SUPPORT && !GKT_CONFIG_RETMEM_DISABLE
#define __RETMEM	__SECTION(.retmem)
#define __RETMEM_SYS	__SECTION(.retmem.sys)
#define __RETMEM_USR	__SECTION(.retmem.usr)

void gkt_retmem_init(void);

enum {
	GKT_RETMEM_LP_NONE = 0,
	GKT_RETMEM_LP_RETENTION,
	GKT_RETMEM_LP_SLEEP,
	GKT_RETMEM_LP_MAX
};
void gkt_retmem_lp(uint32_t mode);

int gkt_retmem_is_reset(void);

#else
#define __RETMEM
#define __RETMEM_SYS
#define __RETMEM_USR

#define gkt_retmem_init()	do {} while(0)
#define gkt_retmem_lp(mode)	do {} while(0)
#define gkt_retmem_is_reset()	0
#endif

#ifdef __cplusplus
}
#endif

#endif	/* GKT_RETMEM_H */

